<?php
/**
 * Ajax操作类
 * @author yaoli<yaoli@pateo.com.cn>
 * @version 1.0 GetUser add by yaoli<yaoli@pateo.com.cn> 
 */
class zixun extends ActionBase1 {
	
	private $date = null;
	
	function init() {
	
	}
	
	/**
	 * 动作
	 *
	 * @see AActionBase::action()
	 */
	public function action() {
		error_reporting(E_ALL);
		$json = get_url_content('http://map.sogou.com/lushu/lushu/getTrackJson/c8808035251312a60125149d703f0070');
		$json = get_url_content('http://map.sogou.com/lushu/lushu/getTrackJson/9a8080ac2180133001218137c6370346');
		#echo "<br>";echo "<br>";echo "<br>";echo "<br>";echo "<br>";
		 $json = iconv("GB2312//IGNORE", "UTF-8", str_replace("'", '"', $json));
		
		$arr = json_decode($json);
		
		 json_last_error();
		dump($arr);exit;
	}
	
	public function phpinfo(){echo phpinfo();}
	
	private function hello(){}
	
	public function Reflection(){
		get_class_all_methods(test,1);
	}
	
	public function getqq(){
		 $url = 'http://xui.ptlogin2.qq.com/cgi-bin/qlogin?domain=qq.com&lang=2052&qtarget=1&jumpname=&appid=549000912&ptcss=undefined&param=u1%253Dhttp%25253A%25252F%25252Fqun.qzone.qq.com%25252Fgroup&css=&mibao_css=&s_url=http%253A%252F%252Fqun.qzone.qq.com%252Fgroup&low_login=0&style=12&authParamUrl=&needVip=1&ptui_version=10028';
		echo $url = "http://xui.ptlogin2.qq.com/cgi-bin/qlogin";
		$url="http://qq.com";
		$url="http://xui.ptlogin2.qq.com/cgi-bin/qlogin";
		load_libra('snoopy');
		
		
	/* 	$handle=fopen($url,"rb");
		$contents=" ";
		while (!feof($handle))
		{
			$contents.=fread($handle,100);
		}
		print_r(htmlspecialchars($contents));
		exit; */
		
		#echo $result = htmlspecialchars(file_get_contents($url));
		
		$snoopy = new Snoopy;
		$snoopy->fetchtext($url);
		echo $snoopy->results;
		
		exit;
		
		$snoopy = new Snoopy;
		$snoopy->fetchtext($url); //获取所有内容
		
		#dumpe($snoopy);
		
		dumpe($snoopy->results); //显示结果
		echo $snoopy->fetchtext; //获取文本内容（去掉html代码）
		$snoopy->fetchlinks; //获取链接
		$snoopy->fetchform; //获取表单
		
		#$result = load_libra('snoopy')->fetch('http://xui.ptlogin2.qq.com/cgi-bin/qlogin?domain=qq.com&amp;lang=2052&amp;qtarget=1&amp;jumpname=&amp;appid=549000912&amp;ptcss=undefined&amp;param=u1%253Dhttp%25253A%25252F%25252Fqun.qzone.qq.com%25252Fgroup&amp;css=&amp;mibao_css=&amp;s_url=http%253A%252F%252Fqun.qzone.qq.com%252Fgroup&amp;low_login=0&amp;style=12&amp;authParamUrl=&amp;needVip=1&amp;ptui_version=10028');
	
	}
	
	public function index(){
		$urlarray=array(
						array('yinyong'=>'海南房地产网','address'=>'海口','url'=>"http://www.hainankf.com/fcnews",'count'=>3),#无水印
						array('yinyong'=>'琼海房地产网','address'=>'琼海','url'=>"http://www.qionghai001.com/fcnews",'url1'=>'http://www.qionghai001.com/2012/fcnews','count'=>12),#无水印
						/* array('临高房地产网',"http://www.lingaofc.com/fcnews/",3),#有水印
						array('三亚房地产网',"http://www.sanyawu.com/fcnews/",5)  #有水印 */
						);
		
		$count=count($urlarray);
		#总共3页
		for($i=0;$i<$count;$i++){
			
			for($y=0;$y<$urlarray[$i]['count'];$y++){
				if($y==0){
					$houzui="/index.html";
				}else{
					$houzui='/'.($y+1).".html";
				}
					
				$content = get_url_content($urlarray[$i]['url'].$houzui);
				#preg_match_all("/<img(.*)src=\"([^\"]+)\"[^>]+>/isU",$this->date['introduction'],$image);
				#echo $content;
				preg_match_all('/<ul class="(.*?)<\/ul>\s*\n*\s*<div id="pages"/isU',$content,$content1);
				
				
				if(isset($urlarray[$i]['url1'])){
					$guize = '/'.str_replace('/', '\/', $urlarray[$i]['url1']).'(.*?)\.html/';
				}else{
					$guize = '/'.str_replace('/', '\/', $urlarray[$i]['url']).'(.*?)\.html/';
				}
				
				preg_match_all($guize, $content1[0][0], $matches);
				
				#preg_match_all('/www\.hainankf\.com\/fcnews\/(.*?)\.html/', $content, $matches);
					
				dump($matches[0]);
				foreach($matches[0] as $key=>$value){
					$this->zixuns($value,$urlarray[$i]['yinyong'],$urlarray[$i]['address']);
				}
			}
			
			
		}
		
	}
	
	
	
	
	private function zixuns($url,$yinyong,$address){
		/* array(12) { ["caid"]=> string(2) "14" ["ccid7"]=> string(0) "" ["ccid13"]=> string(0) ""
				 ["subject"]=> string(16) "编号12345t67u890" ["source"]=> string(10) "黔南房产网" ["keywords"]=> string(0) 
		"" ["abstract"]=> string(0) "" ["thumb"]=> string(0) "" ["content"]=> string(14) "12345rtyu7u890" 
				["clicks"]=> string(1) "0" ["createdate"]=> string(10) "2013-09-08" ["jumpurl"]=> string(0) "" }
		 */
		
		
	/* 	$site_url = 'http://www.lingaofc.com/';
		$site_url="http://www.hainankf.com/";
		
		$rbid="fcnews/0905_373.html"; */
		
	#	$json = get_url_content($site_url.$rbid);
		#$json = iconv("GBK", "UTF-8", str_replace("'", '"', $json));
		
		
		$json = get_url_content($url);
		
		preg_match('/<div class="navboxleft_707E95">([\s\S]*?)<div class="navboxauto_707E95">/', $json, $matchess);
		
		
		
		//获取资讯名称
		preg_match('/<h1>([\s\S]*?)<\/h1>/', $matchess[1], $title);
		
		//获取路书描述
		preg_match('/<div class="padbcont_EB2C97">([\s\S]*?[\s\S])<div class="padbcont_F3B056">/', $matchess[1], $journey);
		
		#标题
		$this->date['subject']=($title[1]);
		#正文
		$this->date['content']=trim(strip_tags($journey[1],'<img><p><strong>'));
		#caid
		$this->date['caid']=14;
		#引用 
		$this->date['source']=$yinyong;
		#加入时间
		$this->date['createdate']='2013-09-08';
		//来源，出处
		
		
		//获取所有图片
		#preg_match_all("/<img(.*)src=\"([^\"]+)\"[^>]+>/isU",$this->date['introduction'],$image);
		dump($this->date);
		#$img = $image[2];
		/* 
		foreach($img as $val){
			preg_match("/^.*\//",$val,$res);                     //先匹配出来图片存储的路径
			echo "<br/>";
			echo str_replace($res[0],"images/",$val);          //将路径全部改成"images/"
		} */
		
		
		#echo ($matchess[1]);
		echo "INSERT INTO cms_archives_sub SET chid='1',needstatics='1378646241,1378646241,'";
		
		exit;
	
		
		
	}
	
	function mst(){
		$str='why?
		No why!
		why no why?
		No why no why!';
		$ar = (explode(chr(13),$str));
		dump($ar[1]);
		dump($str);
	}
	
	function ZZ(){
		preg_match('#(?P<action>\w+)#', '/中国话/dfsadf', $matches);
		var_dump($matches);
	}
		
	
	

}